package main

import (
	"fmt"
	"sort"
)

func main() {
	s1 := make([]int, 5)
	fmt.Println(s1)
	fmt.Println(cap(s1))

	// 通过make函数创建切片

	ss := make([]string, 4)
	ss[0] = "牛逼"
	ss[1] = "牛逼"
	ss[2] = "牛逼"
	ss[3] = "class"
	fmt.Println(ss)

	var origin = [...]int{5, 2, 7, 8, 9}
	fmt.Printf("origin:%v, origin:%d, origin:%d\n", origin, len(origin), cap(origin))
	fmt.Printf("%v\n", &origin[1])
	s2 := origin[:]
	fmt.Printf("%v\n", &s2[1])
	fmt.Printf("s2:%v, len:%d, cap:%d\n", s2, len(s2), cap(s2))

	s2 = append(s2, 10)
	fmt.Printf("s2:%v, len:%d, cap:%d\n", s2, len(s2), cap(s2))

	s3 := s2[1:]
	fmt.Printf("s3:%v, len:%d, cap:%d\n", s3, len(s3), cap(s3))

	s3 = append(s3, 1)
	fmt.Printf("%v\n", &s2[1])
	fmt.Printf("%v\n", &s3[0])
	fmt.Printf("s2:%v, len:%d, cap:%d\n", s2, len(s2), cap(s2))
	fmt.Printf("origin:%v, origin:%d, origin:%d\n", origin, len(origin), cap(origin))

	s3 = append(s3, s2...)
	fmt.Printf("s3:%v, len:%d, cap:%d\n", s3, len(s3), cap(s3))
	fmt.Printf("%v\n", &s3[0])
	var s4 = make([]int, 12, 18)
	// 使用 copy 复制切片--值传递
	copy(s4, s3)
	fmt.Printf("%v\n", &s4[0])
	fmt.Println(s4)
	// 排序--针对切片
	sort.Ints(s4)
	fmt.Println(s4)

}
